package com.zhouhailin.controller;//package com.zhouhailin.controller;

import com.zhouhailin.domain.ResponseResult;
import com.zhouhailin.entity.User;
import com.zhouhailin.service.LoginService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author: zhouhailin
 * @Date : 2024/2/6
 */
@RestController
public class LoginController {

    @Resource
    private LoginService loginService;

    /**
     * 启动服务后，使用Postman测试
     * 1、因为是前后端分离的
     * 2、模拟前端访问后端请求，在请求体中以JSON的格式传入，用户名和密码信息
     *
     * @param user
     * @return
     */
    @PostMapping("/user/login")
    public ResponseResult login(@RequestBody User user) {
        return loginService.login(user);
    }

    @RequestMapping("/user/loginOut")
    public ResponseResult loginOut() {
        return loginService.loginOut();
    }
}
